<?php
/**
 * Zend_Service_Netflix_QueueItem Class.
 *
 * @author Armando Padilla, armando_padilla_81@yahoo.com
 * @package Zend_Service_Netflix
 * 
 */ 
require_once "Utils.php";
 
class Zend_Service_Netflix_AtHomeItem { 
	
	/**
	 * At Home Item Id.
	 *
	 * @var String
	 */
	public $id;

	/**
	 * Last Updated time.
	 *
	 * @var String
	 */
	public $lastUpdated;
	
	/**
	 * Shipped Date.
	 *
	 * @var String
	 */
	public $shippedDate; 
	
	
	/**
	 * Estimated Arrival Date
	 *
	 * @var String
	 */
	public $estimatedArrivalDate;
	
	/**
	 * Title.
	 *
	 * @var String.
	 */
	public $title;
	
	/**
	 * Id of the title.
	 *
	 * @var String.
	 */
	public $titleID;
	
	/**
	 * Title URL Id.  
	 *
	 * @var String.
	 */
	public $titleIDAsURL;
	
	
	public function __construct(){}
	
	/**
	 * Loads the data for the object
	 *
	 * @param SimpleXMLElement $itemXml
	 */
	public function loadXML(SimpleXMLElement $itemXml){
		
		//Set all property values.
		$this->shippedDate 			= (string)$itemXml->shipped_date;
		$this->lastUpdated 	 		= (string)$itemXml->updated;
		$this->estimatedArrivalDate = (string)$itemXml->estimated_arrival_date;
		$this->title    	 		= (string)$itemXml->title['regular'];
		$this->id 					= (string)$itemXml->id;
		
		$xml = simplexml_load_string($itemXml->asXML());
		
		//Get the title id.
		$titleIdInfo = $xml->xpath("link[@rel='http://schemas.netflix.com/catalog/title']");
		foreach($titleIdInfo as $info){
			$this->titleIDAsURL = $info['href']; 
			$this->titleId 		 = Zend_Service_Netflix_Utils::parseTitleId((string)$info['href']);
		}
			
	}
	
}
?>